{extend name="$base" /}
{block name="resources"}
<link rel="stylesheet" type="text/css" href="ADMIN_CSS/member_list.css" />
<script type="text/javascript" src="__STATIC__/My97DatePicker/WdatePicker.js"></script>

{/block}
{block name="main"}
<div class="options-btn">
	<button class="btn-common btn-small" onclick="open_layer('/admin/Mine/addKefu')">添加客服</button>
</div>
<table class="table-class">
	<thead>
		<tr align="center">
			<th ><i class="checkbox-common"><input type="checkbox" onclick="CheckAll(this)"></i></th>
			<th>名称</th>
			<th>客服图片</th>
			<th>排序</th>
			<th>说明</th>
			<th>状态</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody></tbody>
</table>
{/block}
{block name="script"}

<script type="text/javascript">
function LoadingInfo(page_index) {
	var search_text = $("#search_text").val();
	$.ajax({
		type : "post",
		url : document.location,
		data : { "page_index" : page_index, "page_size" :  $("#showNumber").val() },
		success : function(data) {
			if (data["data"].length > 0) {
				$(".table-class tbody").empty();
				for (var i = 0; i < data["data"].length; i++) {
					var html = '';
					html += '<tr align="center">';
					html += '<td><i class="checkbox-common"><input name="sub" type="checkbox" value="'+ data["data"][i]["kf_id"]+'" ></i></td>';
                    html += '<td>'+ data["data"][i]["kf_name"]+'</td>';
                    html += '<td><img src="/'+ data["data"][i]["kf_qr"]+'" style="width:110px;"></td>';
                    html += '<td>'+ data["data"][i]["kf_sort"]+'</td>';
                    html += '<td>'+ data["data"][i]["kf_desc"]+'</td>';
                    html += '<td>'+ data["data"][i]["status"]+'</td>';
                    html += '<td>' +'<a onclick="delete_record('+ data["data"][i]["kf_id"]+')">删除</a></td>';
					html += '</tr>';
					$(".table-class tbody").append(html);
				}
			} else {
				var html = '<tr align="center"><td colspan="7">暂无符合条件的数据记录</td></tr>';
				$(".table-class tbody").html(html);
			}
			initPageData(data["page_count"],data['data'].length,data['total_count']);
			$("#pageNumber").html(pagenumShow(jumpNumber,$("#page_count").val(),{$pageshow}));
		}
	});
}

//全选
function CheckAll(event){
	var checked = event.checked;
	$("#productTbody input[type = 'checkbox']").prop("checked",checked);
	if(checked) $(".table-class tbody input[type = 'checkbox']").parent().addClass("selected");
	else $(".table-class tbody input[type = 'checkbox']").parent().removeClass("selected");
}

// 删除记录
function delete_record(id){
    $( "#dialog" ).dialog({
        buttons: {
            "确定": function() {
                $.ajax({
                    type : "post",
                    url : "{:__URL('ADMIN_MAIN/Mine/kefuDel')}",
                    data : { "id" : id },
                    dataType : "json",
                    success : function(data) {
                        if(data["code"] > 0 ){
                            LoadingInfo(1);
                            showTip(data["message"],'success');
                            $("#chek_all").prop("checked", false);
                        }else{
                            showTip(data["message"],'error');
                        }
                    }
                });
                $(this).dialog('close');
            },
            "取消,#e57373": function() {
                $(this).dialog('close');
            },
        },
        contentText:"确定要删除吗？",
    });
}

/*
* 添加新记录
*/
function open_layer(url){

    layer_index = layer.open({
        type: 2,
        title: '添加矿机',
        shadeClose: true,
        shade: 0.8,
        area: ['90%', '90%'],
        content: url
    });
}
</script>
{/block}